/*
 * CSerial.h
 *
 *  Created on: 2011-4-21
 *      Author: an
 */

#ifndef CSERIAL_H_
#define CSERIAL_H_

#include "SysSeal.h"
#include     <termios.h>    /*PPSIX 终端控制定义*/
class CSerial {
private:
	char rec[10];
    long t_num,t_value;
    int m_value[3];
public:
	CSerial();
	virtual ~CSerial();
	bool OpenSerial(char * serialtag,int serial_num,int baudrate , int databits,int stopbits,int parity);
	virtual void StartIns(){};
	virtual void StopIns(){};
	bool CloseSerial();
	void SendData(unsigned char * data,int size);
	bool StartSerial();
    virtual void OnData(unsigned char cbuf);
	bool SetPwmToStr(long servo_num,long pwmvalue,unsigned char * strvalue);
	bool OnGetPWM(long & servo_num,long  & pwmvalue,char ch);
    int getValue(int num){
        if(num < 0 || num > 2){
            return -1;
        }
        return m_value[num];
    }

	CXThread thread;
	int OpenSerielport;
};

#endif /* CSERIAL_H_ */
